class Solution:
    def reverse(self, x: int) -> int:
        if x == 0:  return 0
        s, ret = str(x), ''
        if '-' in s:
            ret += '-'
            s = s[1:]
        ret += s[::-1].strip('0')
        x = int(ret)
        if x < -2**31 or x > 2**31-1:
            return 0
        return ret


if __name__ == '__main__':
    # n = 1124141414
    # n = -1124141414
    # n = 123456789101
    # n = 1
    # n = 000
    # n = -000
    n = -123
    s = Solution()
    result = s.reverse(n)
    print(result)